Skip to content

feat(agent): OpenCode detection + array-form MCP command audit - #109

Merged
sandstream merged 1 commit into
mainfrom
feat/opencode-detect-arrayform
Jun 27, 2026
Merged

sandstream merged 1 commit into
mainfrom
feat/opencode-detect-arrayform

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Closes two OpenCode-parity gaps from the agent-surface audit. Both land directly on main (independent of any stack).

OpenCode detection (detectAgentTargets) — AGENTS.md is the shared cross-tool rules file that both Codex and OpenCode read. An OpenCode-only project (opencode.json / opencode.jsonc / .opencode, with no .codex or AGENTS.md) was previously not detected, so it never got the managed "use kit" block. It now wires the block into AGENTS.md.

Array-form MCP command (auditMcpStdio) — OpenCode allows command: ["node", "-e", "…"] (binary + args in one array), where Claude/Cursor use a string command + separate args. The stdio audit previously continued on a non-string command, so an inline-code/malware MCP server expressed array-style slipped through. It now handles both shapes; the malware-pattern and inline-eval checks apply to each, and benign array-form (["npx", …]) stays unflagged.

Tests: OpenCode-only detection (opencode.json + .opencode/); array-form inline-code, array-form malware (sh -c curl|sh), benign array-form negative. Full suite 1540/0.

Remaining OpenCode item — a memory/opencode.ts transcript parser — is separate: OpenCode stores per-message JSON under ~/.local/share/opencode/storage/message/<sessionID>/, a different shape from the JSONL harnesses. Tracked for a follow-up once the message schema is verified.


🤖 Generated with Claude Code

https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg


Generated by Claude Code

Two OpenCode-parity gaps from the surface audit:

- detectAgentTargets() now recognizes an OpenCode project (opencode.json /
  opencode.jsonc / .opencode) and wires the managed kit block into AGENTS.md —
  the shared cross-tool rules file that both Codex and OpenCode read. Previously
  an OpenCode-only project (no .codex / AGENTS.md) wasn't detected.
- auditMcpStdio() now handles OpenCode's array-form `command: ["node","-e","…"]`
  (bin + args in one array), not just the string form with a separate `args`.
  The malware-pattern and inline-eval checks apply to both shapes; benign
  array-form (`["npx", …]`) stays unflagged (noise control unchanged).

Tests: OpenCode-only detection (opencode.json + .opencode); array-form inline
code, array-form malware, benign array-form negative. Full suite 1540/0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit f0d2bb5 into main Jun 27, 2026
15 checks passed
@sandstream
sandstream deleted the feat/opencode-detect-arrayform branch June 27, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants